home *** CD-ROM | disk | FTP | other *** search
- #ifndef __MM_MALLOC_H__
- #define __MM_MALLOC_H__
- /*
- * MMmalloc.h
- *
- * Gianni Mariani 8-Apr-1994
- *
- * Extra definitions for MMmalloc not found in <malloc.h>
- *
- */
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #define mm_size_t size_t
- #define mm_ssize_t ssize_t
-
- /* New mallopt commands */
- #define M_LOCKASSIGN 200 /* Assign a lock to an arena */
- #define M_USERDATA 201 /* set the user data field */
-
-
- /* These are recycle mmap/munmap entry points. */
- /* Memory to be unreferenced is unmapped using _mm_munmap and mapped */
- /* using _mm_mmapmem. MMmalloc routines cannot be called inside */
- /* _mm_munmap or _mm_mmapmem. */
- void _mm_munmap(
- register char * p_addr,/* Address to unmap */
- register mm_size_t siz, /* Size of the memory */
- register mm_size_t userdata,
- void * arena
- );
-
- void * _mm_mmapmem(
- register char * p_addr,/* Address to map */
- register mm_size_t siz, /* Size of the memory */
- register mm_size_t userdata,
- void * arena
- );
-
- #define MM_OFFSETOF( ptype, fld ) (( int )&( ( ( ptype ) 0 )->fld ))
- #define MM_ALIGN( val, aval ) ( 1 + ( ( (val) - 1 ) | ( (aval) - 1 ) ) )
-
-
-
- /* ======== MM_CONFIG ================================================= */
- /* PURPOSE:
- * MMmalloc configuration parameters structure
- */
-
- typedef struct MM_CONFIG {
-
- unsigned int mm_ntopromo; /* Number of allocations in a slot*/
- /* before promotion */
-
- int mm_asizshft; /* Number of shifts to get qarena*/
- mm_size_t mm_nqalist; /* Number of quick allocators */
- mm_size_t mm_maxslots; /* Maximum number of slots in qblk*/
- mm_size_t mm_minslots; /* Minimum number of slots in qblk*/
- mm_size_t mm_adjfactor; /* Slot adjustment factor */
- #define MM_ADJSHFT 4
- #define MM_ADJFACTOR( fact ) \
- ( (( unsigned )( fact * (float)(1<<MM_ADJSHFT) )) )
- mm_size_t mm_qblkmult; /* quick block size multiple */
-
- mm_size_t mm_nszmult; /* Roundup val for normal arena */
- #define MM_NFRELVL 3
- struct mm_level {
- mm_size_t mm_flindx; /* Maximum index for this shift*/
- mm_size_t mm_szshft; /* Size shift */
- } mm_xf[ MM_NFRELVL ];
- #define mm_mfreelist mm_xf[MM_NFRELVL-1].mm_flindx
-
- mm_size_t mm_zeromalloc; /* Address given for malloc(0) */
-
- mm_size_t mm_maxsrch; /* maxmimum seeks in the free list*/
- mm_size_t mm_brkmult; /* The size of sbrk requests */
- mm_size_t mm_minrmdr; /* The minimum remainder allowed*/
- mm_size_t mm_gcthresh; /* Threshold to run garbage collector*/
- /* needed before we go and activate*/
- /* Garbage collector */
- mm_size_t mm_missthrash; /* Number of misses in a slot */
- /* Before we run thrash prot */
- mm_size_t mm_flsearh; /* Maximum number of free list srchs*/
- mm_size_t mm_reallthrsh; /* Realloc size threshold for */
- /* ordinary to quick allocs */
- mm_size_t mm_nunmaplists; /* Number of unmap lists - 1 */
- mm_size_t mm_szunmapshift;/* Unmap list shift. */
- mm_size_t mm_unmapalign; /* Alignment of 'unmap'pable memory*/
- mm_size_t mm_minunmapsize;/* Minimum size to unmap */
- mm_size_t mm_minunmapsrch;/* The size of the minimum free list*/
- /* to search when mdealloc'ing */
- mm_size_t mm_minfreerecy; /* Minimum memory freed to next recy*/
- mm_size_t mm_debug_on; /* Is debugging turned on */
- mm_size_t mm_abort_badfree; /* abort on a bad free id true*/
- char mm_clronfree; /* Clear on free val */
- char mm_valclronfree;/* Clear on free value */
- char mm_reportrecy; /* Report recycle ! */
- mm_size_t mm_morefill[ 10 ]; /* More expansion room */
-
- } MM_CONFIG;
-
-
- extern int _mm_defaultoptions;
- extern MM_CONFIG _mm_adfltconfig[];
- extern int _mm_nadfltconfig;
-
- void rerecycle( void );
-
- struct mallinfo qmallinfo( void );
- void malloc_check( void );
- size_t recycle( void );
- void addmem( void * p_mem, mm_size_t size );
-
- struct mallinfo aqmallinfo( void * arena );
- void amalloc_check( void * arena );
- size_t arecycle( void * arena );
- void aaddmem( void * p_mem, mm_size_t size, void * arena );
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* !__MM_MALLOC_H__ */
-
-